//
//  WanfaModel.m
//  SSC
//
//  Created by 红沙尘 on 17/6/17.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "WanfaModel.h"

@interface WanfaModel ()
{
    int _n;
    int _beishu;
    int _zhushu;
    CGFloat _payMoney;
    NSString *_name;
    NSString *_desc;
    NSString *_maxPrice;
    NSMutableArray *_dataArray;
    
}

@end

@implementation WanfaModel

- (id)initWithNamed:(NSString *)name desc:(NSString *)desc maxPrice:(NSString *)maxPrice {
    self = [super init];
    
    if (self) {
        _name = name;
        _desc = desc;
        _maxPrice = maxPrice;
        _beishu = 1;
        
        _dataArray = [[NSMutableArray alloc] init];
        
        NSArray *array = @[];
        
        if ([name isEqualToString:@"一星定位胆▼"]) {
            array = @[@"万位",@"千位",@"百位",@"十位",@"个位"];
            _n = 1;
        } else if ([name isEqualToString:@"前三组六▼"]) {
            array = @[@"前三组六"];
            _n = 3;
        } else if ([name isEqualToString:@"中三组六▼"]) {
            array = @[@"中三组六"];
            _n = 3;
        } else if ([name isEqualToString:@"后三组六▼"]) {
            array = @[@"后三组六"];
            _n = 3;
        } else if ([name isEqualToString:@"前三组三▼"]) {
            array = @[@"前三组三"];
            _n = 2;
        } else if ([name isEqualToString:@"中三组三▼"]) {
            array = @[@"中三组三"];
            _n = 2;
        } else if ([name isEqualToString:@"后三组三▼"]) {
            array = @[@"后三组三"];
            _n = 2;
        } else if ([name isEqualToString:@"趣味>特殊>一帆风顺▼"]) {
            array = @[@"一帆风顺"];
            _n = 1;
        } else if ([name isEqualToString:@"趣味>特殊>好事成双▼"]) {
            array = @[@"好事成双"];
            _n = 1;
        } else if ([name isEqualToString:@"趣味>特殊>三星报喜▼"]) {
            array = @[@"三星报喜"];
            _n = 1;
        } else if ([name isEqualToString:@"趣味>特殊>四季发财▼"]) {
            array = @[@"四季发财"];
            _n = 1;
        } else if ([name isEqualToString:@"龙虎和>万个▼"]) {
            array = @[@"万个"];
            _n = 1;
        }

        for (int i = 0; i < array.count; i ++) {
            HaomaSelectModel *model = [[HaomaSelectModel alloc] initWithWei:array[i]];
            [_dataArray addObject:model];
        }
    }
    
    return self;
}

- (void)updateBeishu:(int)beishu {
    _beishu = beishu;
}

- (CGFloat)payMoneyWithSelectedArray:(NSMutableArray *)selectArray {
    
    int m = (int)selectArray.count;
    int n = self.n;

    if ([self.name isEqualToString:@"前三组三▼"] ||
        [self.name isEqualToString:@"中三组三▼"] ||
        [self.name isEqualToString:@"后三组三▼"] ) {
        _zhushu = [MTool pailieFromM:m n:n];
    } else if ([self.name isEqualToString:@"一星定位胆▼"]) {
        _zhushu = (int)selectArray.count;
    } else {
        _zhushu = [MTool zuheFromM:m n:n];
    }
    
    _payMoney = _zhushu*self.beishu*2.0f;//投注数*倍数*2元
    
    return _payMoney;
}

@end
